﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
namespace Checkers_Beta
{
    public static class SavedData
    {
        public static Data.TileState[] Open(string path)
        {
            Data.TileState[] tmp = new Data.TileState[64];
            FileStream fs = new FileStream(path, FileMode.Open);
            int seek = 0;
            while (seek < 64)
            {
                fs.ReadByte();
            }
            return tmp;
        }
    }
    /// <summary>
    /// This class contains the core game enumerators
    /// and related methods.
    /// </summary>
    public static class Data
    {
        //Target row for White > King
        public static int PlayerGoal = 0;
        //Target row for Black > King
        public static int AIGoal = 7;
        //Quick string conversion
        public static string TileString(TileState tile)
        {
            string tmp = "empty";
            if ((tile & TileState.black) == TileState.black)
            {
                tmp = "Black";
            }
            if ((tile & TileState.white) == TileState.white)
            {
                tmp = "White";
            }
            return tmp;
        }
        public static Cell C(int Row, int Col)
        {
            Cell tmp = new Cell();
            tmp.row = Row;
            tmp.col = Col;
            return tmp;
        }
        // Using a Cell is more logical than just using indices.
        // Cells can be created by using the "C" function and
        // the index can be returned through Index()
        public struct Cell
        {
            public int row;
            public int col;
            public int Index()
            {
                return this.col + (this.row * 8);
            }
        }
        // MoveType is used to mark the definition
        // between 'normal moves' and 'take moves'.
        // The Invalid MoveType is critical to gameplay.
        public enum MoveType : byte
        {
            invalid,
            // Take moves
            takeNW, takeNE,
            takeSW, takeSE,
            // Basic moves
            NW, NE, SW, SE,
            // King move
            king
        }

        // A white king piece on a black tile:
        // TileState.white | TileState.cblack | TileState.king
        [Flags]
        public enum TileState : byte
        {
            empty = 0, white = 1, black = 2, cwhite = 4, cblack = 8, wking = 16, bking = 32
        }
        public enum TurnState : byte
        { 
            white, black
        }
    }
}
